package HZW;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class shujuku {
	static PreparedStatement psmt = null;
	static Statement stmt = null;
	static ResultSet res = null;

	public static Connection getConnection() {
		String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
		String url = "jdbc:sqlserver://" + "192.168.219.55" + ":1433"
				+ ";DatabaseName=WordBase";
		String userName = "sa";
		String userPwd = "Thanks2015";
		Connection connection = null;
		try {
			try {
				Class.forName(driverName);
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
			connection = DriverManager.getConnection(url, userName, userPwd);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return connection;

	}

	/*
	 * public static void main(String[] args) { // TODO Auto-generated method
	 * stub
	 * 
	 * Connection con = getConnection(); ResultSet rs = null; String sql =
	 * "select * from t_base"; try { stmt = con.createStatement();
	 * 
	 * rs = stmt.executeQuery(sql);
	 * 
	 * while(rs.next()){
	 * 
	 * System.out.println(" 词库编号："+rs.getInt("id") +
	 * "词库名称："+rs.getString("basename")); }
	 * 
	 * } catch (SQLException e) { e.printStackTrace(); } }
	 */

	/*
	 * public void test() { // TODO Auto-generated method stub
	 * 
	 * Connection con = getConnection(); ResultSet rs = null; String sql =
	 * "select * from t_base"; try { stmt = con.createStatement();
	 * 
	 * rs = stmt.executeQuery(sql);
	 * 
	 * while(rs.next()){ System.out.println(" 词库编号："+rs.getInt("id") +
	 * "词库名称："+rs.getString("basename")); }
	 * 
	 * } catch (SQLException e) { e.printStackTrace(); }
	 * 
	 * 
	 * 
	 * }
	 */
}
